Added VM_metrics class, taking some of the fields from VM. Make VM.static_max
authorEwan Mellor <ewan@xensource.com>
Tue, 30 Jan 2007 18:30:18 +0000 (18:30 +0000)
committerEwan Mellor <ewan@xensource.com>
Tue, 30 Jan 2007 18:30:18 +0000 (18:30 +0000)
and static_min read-write.  Added VM.VCPUs/{max,at_startup}.  Make
VM.VCPUs/params a string -> string map.

This is the modelling, the C bindings, and the message file -- Xend support to
follow.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
docs/xen-api/xenapi-datamodel.tex
tools/libxen/include/xen_vm.h
tools/libxen/include/xen_vm_metrics.h [new file with mode: 0644]
tools/libxen/include/xen_vm_metrics_decl.h [new file with mode: 0644]
tools/libxen/src/xen_vm.c
tools/libxen/src/xen_vm_metrics.c [new file with mode: 0644]
tools/libxen/test/test_bindings.c
tools/python/xen/xm/messages/en/xen-xm.po

index 2454b28f7a6f72fe4327b3bd52b51558f4302a12..edfb8890bdf674baa0999e2dcabc3ed6f0af3e78 100644 (file)
@@ -25,6 +25,7 @@ Name & Description \\
 {\tt session} & A session \\
 {\tt task} & A long-running asynchronous task \\
 {\tt VM} & A virtual machine (or 'guest') \\
+{\tt VM\_metrics} & The metrics associated with a VM \\
 {\tt host} & A physical host \\
 {\tt host\_metrics} & The metrics associated with a host \\
 {\tt host\_cpu} & A physical CPU \\
@@ -60,6 +61,7 @@ VIF.VM & VM.VIFs & one-to-many\\
 VIF.network & network.VIFs & one-to-many\\
 host.metrics & host\_metrics.host & one-to-one\\
 PIF.metrics & PIF\_metrics.PIF & one-to-one\\
+VM.metrics & VM\_metrics.VM & one-to-one\\
 PIF.host & host.PIFs & one-to-many\\
 PIF.network & network.PIFs & one-to-many\\
 SR.VDIs & VDI.SR & many-to-one\\
@@ -1064,14 +1066,15 @@ $\mathit{RW}$ &  {\tt is\_a\_template} & bool & true if this is a template. Temp
 $\mathit{RW}$ &  {\tt auto\_power\_on} & bool & true if this VM should be started automatically after host boot \\
 $\mathit{RO}_\mathit{run}$ &  {\tt suspend\_VDI} & VDI ref & The VDI that a suspend image is stored on. (Only has meaning if VM is currently suspended) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt resident\_on} & host ref & the host the VM is currently resident on \\
-$\mathit{RO}_\mathit{ins}$ &  {\tt memory/static\_max} & int & Statically-set (i.e. absolute) maximum (bytes) \\
+$\mathit{RW}$ &  {\tt memory/static\_max} & int & Statically-set (i.e. absolute) maximum (bytes) \\
 $\mathit{RW}$ &  {\tt memory/dynamic\_max} & int & Dynamic maximum (bytes) \\
-$\mathit{RO}_\mathit{run}$ &  {\tt memory/actual} & int & Guest's actual usage (bytes) \\
 $\mathit{RW}$ &  {\tt memory/dynamic\_min} & int & Dynamic minimum (bytes) \\
-$\mathit{RO}_\mathit{ins}$ &  {\tt memory/static\_min} & int & Statically-set (i.e. absolute) mininum (bytes) \\
+$\mathit{RW}$ &  {\tt memory/static\_min} & int & Statically-set (i.e. absolute) mininum (bytes) \\
 $\mathit{RW}$ &  {\tt VCPUs/policy} & string & the name of the VCPU scheduling policy to be applied \\
-$\mathit{RW}$ &  {\tt VCPUs/params} & string & string-encoded parameters passed to selected VCPU policy \\
-$\mathit{RW}$ &  {\tt VCPUs/number} & int & Current number of VCPUs \\
+$\mathit{RW}$ &  {\tt VCPUs/params} & (string $\rightarrow$ string) Map & configuration parameters for the selected VCPU policy \\
+$\mathit{RW}$ &  {\tt VCPUs/max} & int & Max number of VCPUs \\
+$\mathit{RW}$ &  {\tt VCPUs/at\_startup} & int & Boot number of VCPUs \\
+$\mathit{RO}_\mathit{ins}$ &  {\tt VCPUs/number} & int & Current number of VCPUs \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
 $\mathit{RW}$ &  {\tt actions/after\_shutdown} & on\_normal\_exit & action to take after the guest has shutdown itself \\
 $\mathit{RW}$ &  {\tt actions/after\_reboot} & on\_normal\_exit & action to take after the guest has rebooted itself \\
@@ -1096,6 +1099,7 @@ $\mathit{RO}_\mathit{ins}$ &  {\tt PCI\_bus} & string & PCI bus path for pass-th
 $\mathit{RO}_\mathit{run}$ &  {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\
 $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
 $\mathit{RO}_\mathit{run}$ &  {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\
+$\mathit{RO}_\mathit{ins}$ &  {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\
 \hline
 \end{longtable}
 \subsection{Additional RPCs associated with class: VM}
@@ -1974,13 +1978,13 @@ value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~get\_memory\_dynamic\_max}
+\subsubsection{RPC name:~set\_memory\_static\_max}
 
 {\bf Overview:} 
-Get the memory/dynamic\_max field of the given VM.
+Set the memory/static\_max field of the given VM.
 
  \noindent {\bf Signature:} 
-\begin{verbatim} int get_memory_dynamic_max (session_id s, VM ref self)\end{verbatim}
+\begin{verbatim} void set_memory_static_max (session_id s, VM ref self, int value)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -1992,27 +1996,29 @@ Get the memory/dynamic\_max field of the given VM.
 {\bf type} & {\bf name} & {\bf description} \\ \hline
 {\tt VM ref } & self & reference to the object \\ \hline 
 
+{\tt int } & value & New value to set \\ \hline 
+
 \end{tabular}
 
 \vspace{0.3cm}
 
  \noindent {\bf Return Type:} 
 {\tt 
-int
+void
 }
 
 
-value of the field
+
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~set\_memory\_dynamic\_max}
+\subsubsection{RPC name:~get\_memory\_dynamic\_max}
 
 {\bf Overview:} 
-Set the memory/dynamic\_max field of the given VM.
+Get the memory/dynamic\_max field of the given VM.
 
  \noindent {\bf Signature:} 
-\begin{verbatim} void set_memory_dynamic_max (session_id s, VM ref self, int value)\end{verbatim}
+\begin{verbatim} int get_memory_dynamic_max (session_id s, VM ref self)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -2024,29 +2030,27 @@ Set the memory/dynamic\_max field of the given VM.
 {\bf type} & {\bf name} & {\bf description} \\ \hline
 {\tt VM ref } & self & reference to the object \\ \hline 
 
-{\tt int } & value & New value to set \\ \hline 
-
 \end{tabular}
 
 \vspace{0.3cm}
 
  \noindent {\bf Return Type:} 
 {\tt 
-void
+int
 }
 
 
-
+value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~get\_memory\_actual}
+\subsubsection{RPC name:~set\_memory\_dynamic\_max}
 
 {\bf Overview:} 
-Get the memory/actual field of the given VM.
+Set the memory/dynamic\_max field of the given VM.
 
  \noindent {\bf Signature:} 
-\begin{verbatim} int get_memory_actual (session_id s, VM ref self)\end{verbatim}
+\begin{verbatim} void set_memory_dynamic_max (session_id s, VM ref self, int value)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -2058,17 +2062,19 @@ Get the memory/actual field of the given VM.
 {\bf type} & {\bf name} & {\bf description} \\ \hline
 {\tt VM ref } & self & reference to the object \\ \hline 
 
+{\tt int } & value & New value to set \\ \hline 
+
 \end{tabular}
 
 \vspace{0.3cm}
 
  \noindent {\bf Return Type:} 
 {\tt 
-int
+void
 }
 
 
-value of the field
+
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
@@ -2167,6 +2173,40 @@ int
 
 
 value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_memory\_static\_min}
+
+{\bf Overview:} 
+Set the memory/static\_min field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_memory_static_min (session_id s, VM ref self, int value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt int } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
@@ -2242,7 +2282,7 @@ void
 Get the VCPUs/params field of the given VM.
 
  \noindent {\bf Signature:} 
-\begin{verbatim} string get_VCPUs_params (session_id s, VM ref self)\end{verbatim}
+\begin{verbatim} ((string -> string) Map) get_VCPUs_params (session_id s, VM ref self)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -2260,7 +2300,7 @@ Get the VCPUs/params field of the given VM.
 
  \noindent {\bf Return Type:} 
 {\tt 
-string
+(string $\rightarrow$ string) Map
 }
 
 
@@ -2274,7 +2314,7 @@ value of the field
 Set the VCPUs/params field of the given VM.
 
  \noindent {\bf Signature:} 
-\begin{verbatim} void set_VCPUs_params (session_id s, VM ref self, string value)\end{verbatim}
+\begin{verbatim} void set_VCPUs_params (session_id s, VM ref self, (string -> string) Map value)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -2286,7 +2326,7 @@ Set the VCPUs/params field of the given VM.
 {\bf type} & {\bf name} & {\bf description} \\ \hline
 {\tt VM ref } & self & reference to the object \\ \hline 
 
-{\tt string } & value & New value to set \\ \hline 
+{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline 
 
 \end{tabular}
 
@@ -2302,13 +2342,84 @@ void
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~get\_VCPUs\_number}
+\subsubsection{RPC name:~add\_to\_VCPUs\_params}
 
 {\bf Overview:} 
-Get the VCPUs/number field of the given VM.
+Add the given key-value pair to the VCPUs/params field of the given VM.
 
  \noindent {\bf Signature:} 
-\begin{verbatim} int get_VCPUs_number (session_id s, VM ref self)\end{verbatim}
+\begin{verbatim} void add_to_VCPUs_params (session_id s, VM ref self, string key, string value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt string } & key & Key to add \\ \hline 
+
+{\tt string } & value & Value to add \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~remove\_from\_VCPUs\_params}
+
+{\bf Overview:} 
+Remove the given key and its corresponding value from the VCPUs/params
+field of the given VM.  If the key is not in that Map, then do nothing.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void remove_from_VCPUs_params (session_id s, VM ref self, string key)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt string } & key & Key to remove \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VCPUs\_max}
+
+{\bf Overview:} 
+Get the VCPUs/max field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} int get_VCPUs_max (session_id s, VM ref self)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -2334,13 +2445,13 @@ value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~set\_VCPUs\_number}
+\subsubsection{RPC name:~set\_VCPUs\_max}
 
 {\bf Overview:} 
-Set the VCPUs/number field of the given VM.
+Set the VCPUs/max field of the given VM.
 
  \noindent {\bf Signature:} 
-\begin{verbatim} void set_VCPUs_number (session_id s, VM ref self, int value)\end{verbatim}
+\begin{verbatim} void set_VCPUs_max (session_id s, VM ref self, int value)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -2365,6 +2476,104 @@ void
 
 
 
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VCPUs\_at\_startup}
+
+{\bf Overview:} 
+Get the VCPUs/at\_startup field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} int get_VCPUs_at_startup (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+int
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_VCPUs\_at\_startup}
+
+{\bf Overview:} 
+Set the VCPUs/at\_startup field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_VCPUs_at_startup (session_id s, VM ref self, int value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt int } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VCPUs\_number}
+
+{\bf Overview:} 
+Get the VCPUs/number field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} int get_VCPUs_number (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+int
+}
+
+
+value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
@@ -3713,6 +3922,38 @@ bool
 }
 
 
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_metrics}
+
+{\bf Overview:} 
+Get the metrics field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VM_metrics ref) get_metrics (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VM\_metrics ref
+}
+
+
 value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
@@ -3879,6 +4120,251 @@ references to objects with match names
 \vspace{0.3cm}
 \vspace{0.3cm}
 
+\vspace{1cm}
+\newpage
+\section{Class: VM\_metrics}
+\subsection{Fields for class: VM\_metrics}
+\begin{longtable}{|lllp{0.38\textwidth}|}
+\hline
+\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VM\_metrics} \\
+\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em
+The metrics associated with a VM.}} \\
+\hline
+Quals & Field & Type & Description \\
+\hline
+$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
+$\mathit{RO}_\mathit{ins}$ &  {\tt VM} & VM ref & VM to which these metrics apply \\
+$\mathit{RO}_\mathit{run}$ &  {\tt memory/actual} & int & Guest's actual memory (bytes) \\
+$\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/number} & int & Current number of VCPUs \\
+$\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
+\hline
+\end{longtable}
+\subsection{Additional RPCs associated with class: VM\_metrics}
+\subsubsection{RPC name:~get\_uuid}
+
+{\bf Overview:} 
+Get the uuid field of the given VM\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_uuid (session_id s, VM_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VM}
+
+{\bf Overview:} 
+Get the VM field of the given VM\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VM ref) get_VM (session_id s, VM_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VM ref
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_memory\_actual}
+
+{\bf Overview:} 
+Get the memory/actual field of the given VM\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} int get_memory_actual (session_id s, VM_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+int
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VCPUs\_number}
+
+{\bf Overview:} 
+Get the VCPUs/number field of the given VM\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} int get_VCPUs_number (session_id s, VM_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+int
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VCPUs\_utilisation}
+
+{\bf Overview:} 
+Get the VCPUs/utilisation field of the given VM\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} ((int -> float) Map) get_VCPUs_utilisation (session_id s, VM_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+(int $\rightarrow$ float) Map
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_by\_uuid}
+
+{\bf Overview:} 
+Get a reference to the VM\_metrics instance with the specified UUID.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VM_metrics ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt string } & uuid & UUID of object to return \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VM\_metrics ref
+}
+
+
+reference to the object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_record}
+
+{\bf Overview:} 
+Get a record containing the current state of the given VM\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VM_metrics record) get_record (session_id s, VM_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VM\_metrics record
+}
+
+
+all fields from the object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+
 \vspace{1cm}
 \newpage
 \section{Class: host}
@@ -11334,6 +11820,16 @@ handle parameter echoes the bad value given.
 \begin{verbatim}VM_HANDLE_INVALID(handle)\end{verbatim}
 \begin{center}\rule{10em}{0.1pt}\end{center}
 
+\subsubsection{VM\_METRICS\_HANDLE\_INVALID}
+
+You gave an invalid VM\_metrics handle.  The VM\_metrics may have recently
+been deleted.  The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VM_METRICS_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
 \subsubsection{VTPM\_HANDLE\_INVALID}
 
 You gave an invalid VTPM handle.  The VTPM may have recently been deleted. 
index f1d83f6f7e89037d73d3846a59fc7729c67376f8..7a56ba482ee65615f2bcace9b21603b2e5b3c438 100644 (file)
@@ -31,6 +31,7 @@
 #include "xen_vdi_decl.h"
 #include "xen_vif_decl.h"
 #include "xen_vm_decl.h"
+#include "xen_vm_metrics_decl.h"
 #include "xen_vm_power_state.h"
 #include "xen_vtpm_decl.h"
 
@@ -114,11 +115,12 @@ typedef struct xen_vm_record
     struct xen_host_record_opt *resident_on;
     int64_t memory_static_max;
     int64_t memory_dynamic_max;
-    int64_t memory_actual;
     int64_t memory_dynamic_min;
     int64_t memory_static_min;
     char *vcpus_policy;
-    char *vcpus_params;
+    xen_string_string_map *vcpus_params;
+    int64_t vcpus_max;
+    int64_t vcpus_at_startup;
     int64_t vcpus_number;
     xen_int_float_map *vcpus_utilisation;
     enum xen_on_normal_exit actions_after_shutdown;
@@ -144,6 +146,7 @@ typedef struct xen_vm_record
     xen_string_string_map *tools_version;
     xen_string_string_map *other_config;
     bool is_control_domain;
+    struct xen_vm_metrics_record_opt *metrics;
 } xen_vm_record;
 
 /**
@@ -339,13 +342,6 @@ extern bool
 xen_vm_get_memory_dynamic_max(xen_session *session, int64_t *result, xen_vm vm);
 
 
-/**
- * Get the memory/actual field of the given VM.
- */
-extern bool
-xen_vm_get_memory_actual(xen_session *session, int64_t *result, xen_vm vm);
-
-
 /**
  * Get the memory/dynamic_min field of the given VM.
  */
@@ -371,7 +367,21 @@ xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm);
  * Get the VCPUs/params field of the given VM.
  */
 extern bool
-xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm);
+xen_vm_get_vcpus_params(xen_session *session, xen_string_string_map **result, xen_vm vm);
+
+
+/**
+ * Get the VCPUs/max field of the given VM.
+ */
+extern bool
+xen_vm_get_vcpus_max(xen_session *session, int64_t *result, xen_vm vm);
+
+
+/**
+ * Get the VCPUs/at_startup field of the given VM.
+ */
+extern bool
+xen_vm_get_vcpus_at_startup(xen_session *session, int64_t *result, xen_vm vm);
 
 
 /**
@@ -549,6 +559,13 @@ extern bool
 xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm);
 
 
+/**
+ * Get the metrics field of the given VM.
+ */
+extern bool
+xen_vm_get_metrics(xen_session *session, xen_vm_metrics *result, xen_vm vm);
+
+
 /**
  * Set the name/label field of the given VM.
  */
@@ -584,6 +601,13 @@ extern bool
 xen_vm_set_auto_power_on(xen_session *session, xen_vm vm, bool auto_power_on);
 
 
+/**
+ * Set the memory/static_max field of the given VM.
+ */
+extern bool
+xen_vm_set_memory_static_max(xen_session *session, xen_vm vm, int64_t static_max);
+
+
 /**
  * Set the memory/dynamic_max field of the given VM.
  */
@@ -598,6 +622,13 @@ extern bool
 xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm vm, int64_t dynamic_min);
 
 
+/**
+ * Set the memory/static_min field of the given VM.
+ */
+extern bool
+xen_vm_set_memory_static_min(xen_session *session, xen_vm vm, int64_t static_min);
+
+
 /**
  * Set the VCPUs/policy field of the given VM.
  */
@@ -609,14 +640,38 @@ xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy);
  * Set the VCPUs/params field of the given VM.
  */
 extern bool
-xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, char *params);
+xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, xen_string_string_map *params);
+
+
+/**
+ * Add the given key-value pair to the VCPUs/params field of the given
+ * VM.
+ */
+extern bool
+xen_vm_add_to_vcpus_params(xen_session *session, xen_vm vm, char *key, char *value);
+
+
+/**
+ * Remove the given key and its corresponding value from the
+ * VCPUs/params field of the given VM.  If the key is not in that Map, then do
+ * nothing.
+ */
+extern bool
+xen_vm_remove_from_vcpus_params(xen_session *session, xen_vm vm, char *key);
+
+
+/**
+ * Set the VCPUs/max field of the given VM.
+ */
+extern bool
+xen_vm_set_vcpus_max(xen_session *session, xen_vm vm, int64_t max);
 
 
 /**
- * Set the VCPUs/number field of the given VM.
+ * Set the VCPUs/at_startup field of the given VM.
  */
 extern bool
-xen_vm_set_vcpus_number(xen_session *session, xen_vm vm, int64_t number);
+xen_vm_set_vcpus_at_startup(xen_session *session, xen_vm vm, int64_t at_startup);
 
 
 /**
diff --git a/tools/libxen/include/xen_vm_metrics.h b/tools/libxen/include/xen_vm_metrics.h
new file mode 100644 (file)
index 0000000..740e327
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+#ifndef XEN_VM_METRICS_H
+#define XEN_VM_METRICS_H
+
+#include "xen_common.h"
+#include "xen_int_float_map.h"
+#include "xen_vm_decl.h"
+#include "xen_vm_metrics_decl.h"
+
+
+/*
+ * The VM_metrics class.
+ * 
+ * The metrics associated with a VM.
+ */
+
+
+/**
+ * Free the given xen_vm_metrics.  The given handle must have been
+ * allocated by this library.
+ */
+extern void
+xen_vm_metrics_free(xen_vm_metrics vm_metrics);
+
+
+typedef struct xen_vm_metrics_set
+{
+    size_t size;
+    xen_vm_metrics *contents[];
+} xen_vm_metrics_set;
+
+/**
+ * Allocate a xen_vm_metrics_set of the given size.
+ */
+extern xen_vm_metrics_set *
+xen_vm_metrics_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vm_metrics_set.  The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_vm_metrics_set_free(xen_vm_metrics_set *set);
+
+
+typedef struct xen_vm_metrics_record
+{
+    xen_vm_metrics handle;
+    char *uuid;
+    struct xen_vm_record_opt *vm;
+    int64_t memory_actual;
+    int64_t vcpus_number;
+    xen_int_float_map *vcpus_utilisation;
+} xen_vm_metrics_record;
+
+/**
+ * Allocate a xen_vm_metrics_record.
+ */
+extern xen_vm_metrics_record *
+xen_vm_metrics_record_alloc(void);
+
+/**
+ * Free the given xen_vm_metrics_record, and all referenced values. 
+ * The given record must have been allocated by this library.
+ */
+extern void
+xen_vm_metrics_record_free(xen_vm_metrics_record *record);
+
+
+typedef struct xen_vm_metrics_record_opt
+{
+    bool is_record;
+    union
+    {
+        xen_vm_metrics handle;
+        xen_vm_metrics_record *record;
+    } u;
+} xen_vm_metrics_record_opt;
+
+/**
+ * Allocate a xen_vm_metrics_record_opt.
+ */
+extern xen_vm_metrics_record_opt *
+xen_vm_metrics_record_opt_alloc(void);
+
+/**
+ * Free the given xen_vm_metrics_record_opt, and all referenced values.
+ *  The given record_opt must have been allocated by this library.
+ */
+extern void
+xen_vm_metrics_record_opt_free(xen_vm_metrics_record_opt *record_opt);
+
+
+typedef struct xen_vm_metrics_record_set
+{
+    size_t size;
+    xen_vm_metrics_record *contents[];
+} xen_vm_metrics_record_set;
+
+/**
+ * Allocate a xen_vm_metrics_record_set of the given size.
+ */
+extern xen_vm_metrics_record_set *
+xen_vm_metrics_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vm_metrics_record_set, and all referenced values.
+ *  The given set must have been allocated by this library.
+ */
+extern void
+xen_vm_metrics_record_set_free(xen_vm_metrics_record_set *set);
+
+
+
+typedef struct xen_vm_metrics_record_opt_set
+{
+    size_t size;
+    xen_vm_metrics_record_opt *contents[];
+} xen_vm_metrics_record_opt_set;
+
+/**
+ * Allocate a xen_vm_metrics_record_opt_set of the given size.
+ */
+extern xen_vm_metrics_record_opt_set *
+xen_vm_metrics_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vm_metrics_record_opt_set, and all referenced
+ * values.  The given set must have been allocated by this library.
+ */
+extern void
+xen_vm_metrics_record_opt_set_free(xen_vm_metrics_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_record(xen_session *session, xen_vm_metrics_record **result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get a reference to the VM_metrics instance with the specified UUID.
+ */
+extern bool
+xen_vm_metrics_get_by_uuid(xen_session *session, xen_vm_metrics *result, char *uuid);
+
+
+/**
+ * Get the uuid field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_uuid(xen_session *session, char **result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get the VM field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get the memory/actual field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_memory_actual(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get the VCPUs/number field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_vcpus_number(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get the VCPUs/utilisation field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm_metrics vm_metrics);
+
+
+#endif
diff --git a/tools/libxen/include/xen_vm_metrics_decl.h b/tools/libxen/include/xen_vm_metrics_decl.h
new file mode 100644 (file)
index 0000000..ea1bcb5
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+#ifndef XEN_VM_METRICS_DECL_H
+#define XEN_VM_METRICS_DECL_H
+
+typedef void *xen_vm_metrics;
+
+struct xen_vm_metrics_set;
+struct xen_vm_metrics_record;
+struct xen_vm_metrics_record_set;
+struct xen_vm_metrics_record_opt;
+struct xen_vm_metrics_record_opt_set;
+
+#endif
index 4a7787825f5cf10b0d29694d6e31fbd1da8868b0..6cbc3670b04ec826dd25cb60f0975e683db3e1ee 100644 (file)
@@ -33,6 +33,7 @@
 #include "xen_vdi.h"
 #include "xen_vif.h"
 #include "xen_vm.h"
+#include "xen_vm_metrics.h"
 #include "xen_vm_power_state_internal.h"
 #include "xen_vtpm.h"
 
@@ -81,9 +82,6 @@ static const struct_member xen_vm_record_struct_members[] =
         { .key = "memory_dynamic_max",
           .type = &abstract_type_int,
           .offset = offsetof(xen_vm_record, memory_dynamic_max) },
-        { .key = "memory_actual",
-          .type = &abstract_type_int,
-          .offset = offsetof(xen_vm_record, memory_actual) },
         { .key = "memory_dynamic_min",
           .type = &abstract_type_int,
           .offset = offsetof(xen_vm_record, memory_dynamic_min) },
@@ -94,8 +92,14 @@ static const struct_member xen_vm_record_struct_members[] =
           .type = &abstract_type_string,
           .offset = offsetof(xen_vm_record, vcpus_policy) },
         { .key = "VCPUs_params",
-          .type = &abstract_type_string,
+          .type = &abstract_type_string_string_map,
           .offset = offsetof(xen_vm_record, vcpus_params) },
+        { .key = "VCPUs_max",
+          .type = &abstract_type_int,
+          .offset = offsetof(xen_vm_record, vcpus_max) },
+        { .key = "VCPUs_at_startup",
+          .type = &abstract_type_int,
+          .offset = offsetof(xen_vm_record, vcpus_at_startup) },
         { .key = "VCPUs_number",
           .type = &abstract_type_int,
           .offset = offsetof(xen_vm_record, vcpus_number) },
@@ -170,7 +174,10 @@ static const struct_member xen_vm_record_struct_members[] =
           .offset = offsetof(xen_vm_record, other_config) },
         { .key = "is_control_domain",
           .type = &abstract_type_bool,
-          .offset = offsetof(xen_vm_record, is_control_domain) }
+          .offset = offsetof(xen_vm_record, is_control_domain) },
+        { .key = "metrics",
+          .type = &abstract_type_ref,
+          .offset = offsetof(xen_vm_record, metrics) }
     };
 
 const abstract_type xen_vm_record_abstract_type_ =
@@ -197,7 +204,7 @@ xen_vm_record_free(xen_vm_record *record)
     xen_vdi_record_opt_free(record->suspend_vdi);
     xen_host_record_opt_free(record->resident_on);
     free(record->vcpus_policy);
-    free(record->vcpus_params);
+    xen_string_string_map_free(record->vcpus_params);
     xen_int_float_map_free(record->vcpus_utilisation);
     xen_console_record_opt_set_free(record->consoles);
     xen_vif_record_opt_set_free(record->vifs);
@@ -214,6 +221,7 @@ xen_vm_record_free(xen_vm_record *record)
     free(record->pci_bus);
     xen_string_string_map_free(record->tools_version);
     xen_string_string_map_free(record->other_config);
+    xen_vm_metrics_record_opt_free(record->metrics);
     free(record);
 }
 
@@ -470,7 +478,7 @@ xen_vm_get_memory_dynamic_max(xen_session *session, int64_t *result, xen_vm vm)
 
 
 bool
-xen_vm_get_memory_actual(xen_session *session, int64_t *result, xen_vm vm)
+xen_vm_get_memory_dynamic_min(xen_session *session, int64_t *result, xen_vm vm)
 {
     abstract_value param_values[] =
         {
@@ -480,13 +488,13 @@ xen_vm_get_memory_actual(xen_session *session, int64_t *result, xen_vm vm)
 
     abstract_type result_type = abstract_type_int;
 
-    XEN_CALL_("VM.get_memory_actual");
+    XEN_CALL_("VM.get_memory_dynamic_min");
     return session->ok;
 }
 
 
 bool
-xen_vm_get_memory_dynamic_min(xen_session *session, int64_t *result, xen_vm vm)
+xen_vm_get_memory_static_min(xen_session *session, int64_t *result, xen_vm vm)
 {
     abstract_value param_values[] =
         {
@@ -496,13 +504,13 @@ xen_vm_get_memory_dynamic_min(xen_session *session, int64_t *result, xen_vm vm)
 
     abstract_type result_type = abstract_type_int;
 
-    XEN_CALL_("VM.get_memory_dynamic_min");
+    XEN_CALL_("VM.get_memory_static_min");
     return session->ok;
 }
 
 
 bool
-xen_vm_get_memory_static_min(xen_session *session, int64_t *result, xen_vm vm)
+xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm)
 {
     abstract_value param_values[] =
         {
@@ -510,15 +518,16 @@ xen_vm_get_memory_static_min(xen_session *session, int64_t *result, xen_vm vm)
               .u.string_val = vm }
         };
 
-    abstract_type result_type = abstract_type_int;
+    abstract_type result_type = abstract_type_string;
 
-    XEN_CALL_("VM.get_memory_static_min");
+    *result = NULL;
+    XEN_CALL_("VM.get_VCPUs_policy");
     return session->ok;
 }
 
 
 bool
-xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm)
+xen_vm_get_vcpus_params(xen_session *session, xen_string_string_map **result, xen_vm vm)
 {
     abstract_value param_values[] =
         {
@@ -526,16 +535,16 @@ xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm)
               .u.string_val = vm }
         };
 
-    abstract_type result_type = abstract_type_string;
+    abstract_type result_type = abstract_type_string_string_map;
 
     *result = NULL;
-    XEN_CALL_("VM.get_VCPUs_policy");
+    XEN_CALL_("VM.get_VCPUs_params");
     return session->ok;
 }
 
 
 bool
-xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm)
+xen_vm_get_vcpus_max(xen_session *session, int64_t *result, xen_vm vm)
 {
     abstract_value param_values[] =
         {
@@ -543,10 +552,25 @@ xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm)
               .u.string_val = vm }
         };
 
-    abstract_type result_type = abstract_type_string;
+    abstract_type result_type = abstract_type_int;
 
-    *result = NULL;
-    XEN_CALL_("VM.get_VCPUs_params");
+    XEN_CALL_("VM.get_VCPUs_max");
+    return session->ok;
+}
+
+
+bool
+xen_vm_get_vcpus_at_startup(xen_session *session, int64_t *result, xen_vm vm)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm }
+        };
+
+    abstract_type result_type = abstract_type_int;
+
+    XEN_CALL_("VM.get_VCPUs_at_startup");
     return session->ok;
 }
 
@@ -964,6 +988,23 @@ xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm)
 }
 
 
+bool
+xen_vm_get_metrics(xen_session *session, xen_vm_metrics *result, xen_vm vm)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("VM.get_metrics");
+    return session->ok;
+}
+
+
 bool
 xen_vm_set_name_label(xen_session *session, xen_vm vm, char *label)
 {
@@ -1044,6 +1085,22 @@ xen_vm_set_auto_power_on(xen_session *session, xen_vm vm, bool auto_power_on)
 }
 
 
+bool
+xen_vm_set_memory_static_max(xen_session *session, xen_vm vm, int64_t static_max)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm },
+            { .type = &abstract_type_int,
+              .u.int_val = static_max }
+        };
+
+    xen_call_(session, "VM.set_memory_static_max", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
 bool
 xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm vm, int64_t dynamic_max)
 {
@@ -1076,6 +1133,22 @@ xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm vm, int64_t dynamic_m
 }
 
 
+bool
+xen_vm_set_memory_static_min(xen_session *session, xen_vm vm, int64_t static_min)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm },
+            { .type = &abstract_type_int,
+              .u.int_val = static_min }
+        };
+
+    xen_call_(session, "VM.set_memory_static_min", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
 bool
 xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy)
 {
@@ -1093,14 +1166,14 @@ xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy)
 
 
 bool
-xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, char *params)
+xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, xen_string_string_map *params)
 {
     abstract_value param_values[] =
         {
             { .type = &abstract_type_string,
               .u.string_val = vm },
-            { .type = &abstract_type_string,
-              .u.string_val = params }
+            { .type = &abstract_type_string_string_map,
+              .u.set_val = (arbitrary_set *)params }
         };
 
     xen_call_(session, "VM.set_VCPUs_params", param_values, 2, NULL, NULL);
@@ -1109,17 +1182,67 @@ xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, char *params)
 
 
 bool
-xen_vm_set_vcpus_number(xen_session *session, xen_vm vm, int64_t number)
+xen_vm_add_to_vcpus_params(xen_session *session, xen_vm vm, char *key, char *value)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm },
+            { .type = &abstract_type_string,
+              .u.string_val = key },
+            { .type = &abstract_type_string,
+              .u.string_val = value }
+        };
+
+    xen_call_(session, "VM.add_to_VCPUs_params", param_values, 3, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_vm_remove_from_vcpus_params(xen_session *session, xen_vm vm, char *key)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm },
+            { .type = &abstract_type_string,
+              .u.string_val = key }
+        };
+
+    xen_call_(session, "VM.remove_from_VCPUs_params", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_vm_set_vcpus_max(xen_session *session, xen_vm vm, int64_t max)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm },
+            { .type = &abstract_type_int,
+              .u.int_val = max }
+        };
+
+    xen_call_(session, "VM.set_VCPUs_max", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_vm_set_vcpus_at_startup(xen_session *session, xen_vm vm, int64_t at_startup)
 {
     abstract_value param_values[] =
         {
             { .type = &abstract_type_string,
               .u.string_val = vm },
             { .type = &abstract_type_int,
-              .u.int_val = number }
+              .u.int_val = at_startup }
         };
 
-    xen_call_(session, "VM.set_VCPUs_number", param_values, 2, NULL, NULL);
+    xen_call_(session, "VM.set_VCPUs_at_startup", param_values, 2, NULL, NULL);
     return session->ok;
 }
 
diff --git a/tools/libxen/src/xen_vm_metrics.c b/tools/libxen/src/xen_vm_metrics.c
new file mode 100644 (file)
index 0000000..03a08d8
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_int_float_map.h"
+#include "xen_internal.h"
+#include "xen_vm.h"
+#include "xen_vm_metrics.h"
+
+
+XEN_FREE(xen_vm_metrics)
+XEN_SET_ALLOC_FREE(xen_vm_metrics)
+XEN_ALLOC(xen_vm_metrics_record)
+XEN_SET_ALLOC_FREE(xen_vm_metrics_record)
+XEN_ALLOC(xen_vm_metrics_record_opt)
+XEN_RECORD_OPT_FREE(xen_vm_metrics)
+XEN_SET_ALLOC_FREE(xen_vm_metrics_record_opt)
+
+
+static const struct_member xen_vm_metrics_record_struct_members[] =
+    {
+        { .key = "uuid",
+          .type = &abstract_type_string,
+          .offset = offsetof(xen_vm_metrics_record, uuid) },
+        { .key = "VM",
+          .type = &abstract_type_ref,
+          .offset = offsetof(xen_vm_metrics_record, vm) },
+        { .key = "memory_actual",
+          .type = &abstract_type_int,
+          .offset = offsetof(xen_vm_metrics_record, memory_actual) },
+        { .key = "VCPUs_number",
+          .type = &abstract_type_int,
+          .offset = offsetof(xen_vm_metrics_record, vcpus_number) },
+        { .key = "VCPUs_utilisation",
+          .type = &abstract_type_int_float_map,
+          .offset = offsetof(xen_vm_metrics_record, vcpus_utilisation) }
+    };
+
+const abstract_type xen_vm_metrics_record_abstract_type_ =
+    {
+       .typename = STRUCT,
+       .struct_size = sizeof(xen_vm_metrics_record),
+       .member_count =
+           sizeof(xen_vm_metrics_record_struct_members) / sizeof(struct_member),
+       .members = xen_vm_metrics_record_struct_members
+    };
+
+
+void
+xen_vm_metrics_record_free(xen_vm_metrics_record *record)
+{
+    if (record == NULL)
+    {
+        return;
+    }
+    free(record->handle);
+    free(record->uuid);
+    xen_vm_record_opt_free(record->vm);
+    xen_int_float_map_free(record->vcpus_utilisation);
+    free(record);
+}
+
+
+bool
+xen_vm_metrics_get_record(xen_session *session, xen_vm_metrics_record **result, xen_vm_metrics vm_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm_metrics }
+        };
+
+    abstract_type result_type = xen_vm_metrics_record_abstract_type_;
+
+    *result = NULL;
+    XEN_CALL_("VM_metrics.get_record");
+
+    if (session->ok)
+    {
+       (*result)->handle = xen_strdup_((*result)->uuid);
+    }
+
+    return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_by_uuid(xen_session *session, xen_vm_metrics *result, char *uuid)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = uuid }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("VM_metrics.get_by_uuid");
+    return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm_metrics }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("VM_metrics.get_VM");
+    return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_memory_actual(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm_metrics }
+        };
+
+    abstract_type result_type = abstract_type_int;
+
+    XEN_CALL_("VM_metrics.get_memory_actual");
+    return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_vcpus_number(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm_metrics }
+        };
+
+    abstract_type result_type = abstract_type_int;
+
+    XEN_CALL_("VM_metrics.get_VCPUs_number");
+    return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm_metrics vm_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm_metrics }
+        };
+
+    abstract_type result_type = abstract_type_int_float_map;
+
+    *result = NULL;
+    XEN_CALL_("VM_metrics.get_VCPUs_utilisation");
+    return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_uuid(xen_session *session, char **result, xen_vm_metrics vm_metrics)
+{
+    *result = session->ok ? xen_strdup_((char *)vm_metrics) : NULL;
+    return session->ok;
+}
index cfd1fb69e7c928fe42b159fef74700d113119613..88fce8b35b6e0d45f944130c76d5fbcdb73b9c81 100644 (file)
@@ -277,6 +277,7 @@ int main(int argc, char **argv)
  */
 static xen_vm create_new_vm(xen_session *session)
 {
+    xen_string_string_map *vcpus_params = xen_string_string_map_alloc(1);
     xen_vm_record vm_record =
         {
             .name_label = "NewVM",
@@ -288,7 +289,7 @@ static xen_vm create_new_vm(xen_session *session)
             .memory_dynamic_min = 128,
             .memory_static_min = 128,
             .vcpus_policy = "credit",
-            .vcpus_params = "",
+            .vcpus_params = vcpus_params,
             .vcpus_number = 2,
             .actions_after_shutdown = XEN_ON_NORMAL_EXIT_DESTROY,
             .actions_after_reboot = XEN_ON_NORMAL_EXIT_RESTART,
index e71ca8cb13c4769c3d655289c9457b29e3716bae..d422b2e6b8108d53c6b07b16378832652d0b3c61 100644 (file)
@@ -19,7 +19,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: Xen-xm 3.0\n"
-"PO-Revision-Date: 2007-01-30 12:49+0000\n"
+"PO-Revision-Date: 2007-01-30 17:15+0000\n"
 "Last-Translator: Ewan Mellor <ewan@xensource.com>\n"
 "Language-Team: xen-devel <xen-devel@lists.xensource.com>\n"
 "MIME-Version: 1.0\n"
@@ -74,6 +74,9 @@ msgstr "The VIF handle %(1)s is invalid."
 msgid "VM_HANDLE_INVALID"
 msgstr "The VM handle %(1)s is invalid."
 
+msgid "VM_METRICS_HANDLE_INVALID"
+msgstr "The VM_metrics handle %(1)s is invalid."
+
 msgid "VTPM_HANDLE_INVALID"
 msgstr "The VTPM handle %(1)s is invalid."